package com.SouthernWall_404.age_tool.common.API;

import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.vehicle.Minecart;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.Vec3;

public class GeneralAPI {
    /*
    用于获取两坐标之间距离的函数
     */
    public static float getDistance(BlockPos blockPos1, BlockPos blockPos2)
    {
        Vec3 vec=new Vec3(blockPos1.getX()-blockPos2.getX(),blockPos1.getY()-blockPos2.getY(),blockPos1.getZ()-blockPos2.getZ());
        return (float) vec.length();
    }
    /*
    获取玩家距坐标距离
     */
    public static float getDistanceToLocalPlayer(BlockPos blockPos)
    {
        LocalPlayer localPlayer= Minecraft.getInstance().player;
        return getDistance(blockPos,localPlayer.getOnPos());
    }
}
